home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / prolog / ai.prl / mike1.exe / CARBKWD.KB < prev    next >
Encoding:
Text File  |  1990-09-14  |  2.1 KB  |  58 lines

  1. /* 'Deep causal reasoning' diagnosis of car starting problems,
  2. based on Luc Steels article "Components of Expertise" in AI Magazine,
  3. Vol. 11, No. 2, 1990. */
  4.  
  5. /*
  6. Backward chaining version (see CARFWD.KB for forward chaining version)
  7. */
  8.  
  9. rule init forward         /* Initialize working memory with problem */
  10.   if start
  11.   then
  12.    remove start &
  13.    add [transmission-ok, prereq, engine-starts] &
  14.    add [starter-turning, prereq, engine-starts] &
  15.    add [plug1-fires, prereq, engine-starts] &
  16.    add [plug2-fires, prereq, engine-starts] &
  17.    add [plug3-fires, prereq, engine-starts] &
  18.    add [plug4-fires, prereq, engine-starts] &
  19.    add [cable1-ok, prereq, plug1-fires] &
  20.    add [cable2-ok, prereq, plug2-fires] &
  21.    add [cable3-ok, prereq, plug3-fires] &
  22.    add [cable4-ok, prereq, plug4-fires] &
  23.    add [coil-powered, prereq, X-fires] &
  24.    add [starter-powered, prereq, starter-turning] &
  25.    add [battery-charged, prereq, starter-powered] &
  26.    add [battery-charged, prereq, coil-powered] &
  27.    add [need_to_investigate, engine-starts].  /* set focus of problem */
  28.  
  29. rule run_it forward
  30.   if
  31.     [need_to_investigate, X] &               /* retrieve focus */
  32.     deduce [X,has_root_cause,Obj-State]     /* initiate backward-chain */
  33.   then
  34.     announce [Obj,' is a source of difficulty', nl,
  35.                  'so you should fix it and try again.'] &
  36.     halt.  /* single fault assumption! */
  37.  
  38. rule i_am_bad backward
  39.   if
  40.     [observation,X,no] &      /* found a troublesome object...*/
  41.     -- [P,prereq,X]           /* which has no prerequisite links? */
  42.   then
  43.     [X,has_root_cause,X].     /* then that guy is the root cause! */
  44.  
  45. rule you_are_bad backward
  46.   if
  47.     [observation,X,no] &     /* found a troublesome object X... */
  48.     [P,prereq,X] &           /* which DOES have a prerequisite P */
  49.     [P,has_root_cause,Root]  /* and P's problems are really due to Root */
  50.   then
  51.     [X,has_root_cause,Root]. /* then attribute X's problems to Root */
  52.  
  53. rule ask_it backward         /* N.B. assumes a yes or no response!!! */
  54.      if
  55.        query ['Is it the case that',Obj-State] receives_answer Ans
  56.      then
  57.        [observation,Obj-State,Ans].
  58.